<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.4.0">


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">



<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@5.15.4/css/all.min.css" integrity="sha256-mUZM63G8m73Mcidfrv5E+Y61y7a12O5mW4ezU3bxqW4=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/animate.css@3.1.1/animate.min.css" integrity="sha256-PR7ttpcvz8qrF57fur/yAx1qXMFJeJFiA6pSzWi0OIE=" crossorigin="anonymous">

<script class="next-config" data-name="main" type="application/json">{"hostname":"tallgy.gitee.io","root":"/","images":"/images","scheme":"Muse","darkmode":false,"version":"8.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12},"copycode":false,"bookmark":{"enable":false,"color":"#222","save":"auto"},"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"stickytabs":false,"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"fadeInDown","post_body":"fadeInDown","coll_header":"fadeInLeft","sidebar":"fadeInUp"}},"prism":false,"i18n":{"placeholder":"搜索...","empty":"没有找到任何搜索结果：${query}","hits_time":"找到 ${hits} 个搜索结果（用时 ${time} 毫秒）","hits":"找到 ${hits} 个搜索结果"}}</script><script src="/js/config.js"></script>
<meta name="description" content="uni-app 项目开发笔记问题不要挂载原型链将对象挂载在原型链是一个大忌，并且vue2也有警告，因为这样对于维护是一个非常大的问题，使用 forin会将内容显示出来 1Object.prototype.a &#x3D; &amp;#123;&amp;#125;    sass的使用对于根项目的 uni.scss 我们在使用的时候不需要进行引入。 项目的 node_modules vue-cli-plugin-uni&#x2F;li">
<meta property="og:type" content="article">
<meta property="og:title" content="uni-app-projec笔记">
<meta property="og:url" content="http://tallgy.gitee.io/2022/01/08/%E9%9A%8F%E7%AC%94/uni-app-projec%E7%AC%94%E8%AE%B0/index.html">
<meta property="og:site_name" content="tallgy&#39;s blog">
<meta property="og:description" content="uni-app 项目开发笔记问题不要挂载原型链将对象挂载在原型链是一个大忌，并且vue2也有警告，因为这样对于维护是一个非常大的问题，使用 forin会将内容显示出来 1Object.prototype.a &#x3D; &amp;#123;&amp;#125;    sass的使用对于根项目的 uni.scss 我们在使用的时候不需要进行引入。 项目的 node_modules vue-cli-plugin-uni&#x2F;li">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2022-01-08T08:44:02.000Z">
<meta property="article:modified_time" content="2023-06-25T08:57:29.338Z">
<meta property="article:author" content="tallgy">
<meta property="article:tag" content="随笔">
<meta property="article:tag" content="项目">
<meta property="article:tag" content="微信小程序">
<meta property="article:tag" content="uniapp">
<meta name="twitter:card" content="summary">


<link rel="canonical" href="http://tallgy.gitee.io/2022/01/08/%E9%9A%8F%E7%AC%94/uni-app-projec%E7%AC%94%E8%AE%B0/">



<script class="next-config" data-name="page" type="application/json">{"sidebar":"","isHome":false,"isPost":true,"lang":"zh-CN","comments":true,"permalink":"http://tallgy.gitee.io/2022/01/08/%E9%9A%8F%E7%AC%94/uni-app-projec%E7%AC%94%E8%AE%B0/","path":"2022/01/08/随笔/uni-app-projec笔记/","title":"uni-app-projec笔记"}</script>

<script class="next-config" data-name="calendar" type="application/json">""</script>
<title>uni-app-projec笔记 | tallgy's blog</title>
  




  <noscript>
    <link rel="stylesheet" href="/css/noscript.css">
  </noscript>
</head>

<body itemscope itemtype="http://schema.org/WebPage" class="use-motion">
  <div class="headband"></div>

  <main class="main">
    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏" role="button">
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <i class="logo-line"></i>
      <h1 class="site-title">tallgy's blog</h1>
      <i class="logo-line"></i>
    </a>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
    </div>
  </div>
</div>







</div>
        
  
  <div class="toggle sidebar-toggle" role="button">
    <span class="toggle-line"></span>
    <span class="toggle-line"></span>
    <span class="toggle-line"></span>
  </div>

  <aside class="sidebar">

    <div class="sidebar-inner sidebar-nav-active sidebar-toc-active">
      <ul class="sidebar-nav">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <div class="sidebar-panel-container">
        <!--noindex-->
        <div class="post-toc-wrap sidebar-panel">
            <div class="post-toc animated"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#uni-app-%E9%A1%B9%E7%9B%AE%E5%BC%80%E5%8F%91%E7%AC%94%E8%AE%B0%E9%97%AE%E9%A2%98"><span class="nav-number">1.</span> <span class="nav-text">uni-app 项目开发笔记问题</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#%E4%B8%8D%E8%A6%81%E6%8C%82%E8%BD%BD%E5%8E%9F%E5%9E%8B%E9%93%BE"><span class="nav-number">1.1.</span> <span class="nav-text">不要挂载原型链</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#sass%E7%9A%84%E4%BD%BF%E7%94%A8"><span class="nav-number">1.2.</span> <span class="nav-text">sass的使用</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#tabBar"><span class="nav-number">1.3.</span> <span class="nav-text">tabBar</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E8%B7%AF%E7%94%B1-router"><span class="nav-number">1.4.</span> <span class="nav-text">路由 router</span></a></li></ol></li></ol></div>
        </div>
        <!--/noindex-->

        <div class="site-overview-wrap sidebar-panel">
          <div class="site-author site-overview-item animated" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">tallgy</p>
  <div class="site-description" itemprop="description">只是一个知识的搬运工</div>
</div>
<div class="site-state-wrap site-overview-item animated">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
        <a href="/archives/">
          <span class="site-state-item-count">107</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
          <a href="/categories/">
        <span class="site-state-item-count">32</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
          <a href="/tags/">
        <span class="site-state-item-count">74</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>



        </div>
      </div>
    </div>
  </aside>
  <div class="sidebar-dimmer"></div>


    </header>

    
  <div class="back-to-top" role="button" aria-label="返回顶部">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>

<noscript>
  <div class="noscript-warning">Theme NexT works best with JavaScript enabled</div>
</noscript>


    <div class="main-inner post posts-expand">


  


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://tallgy.gitee.io/2022/01/08/%E9%9A%8F%E7%AC%94/uni-app-projec%E7%AC%94%E8%AE%B0/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="tallgy">
      <meta itemprop="description" content="只是一个知识的搬运工">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="tallgy's blog">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          uni-app-projec笔记
        </h1>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">发表于</span>

      <time title="创建时间：2022-01-08 16:44:02" itemprop="dateCreated datePublished" datetime="2022-01-08T16:44:02+08:00">2022-01-08</time>
    </span>
      <span class="post-meta-item">
        <span class="post-meta-item-icon">
          <i class="far fa-calendar-check"></i>
        </span>
        <span class="post-meta-item-text">更新于</span>
        <time title="修改时间：2023-06-25 16:57:29" itemprop="dateModified" datetime="2023-06-25T16:57:29+08:00">2023-06-25</time>
      </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-folder"></i>
      </span>
      <span class="post-meta-item-text">分类于</span>
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/%E9%9A%8F%E7%AC%94/" itemprop="url" rel="index"><span itemprop="name">随笔</span></a>
        </span>
    </span>

  
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">
        <h1 id="uni-app-项目开发笔记问题"><a href="#uni-app-项目开发笔记问题" class="headerlink" title="uni-app 项目开发笔记问题"></a>uni-app 项目开发笔记问题</h1><h2 id="不要挂载原型链"><a href="#不要挂载原型链" class="headerlink" title="不要挂载原型链"></a>不要挂载原型链</h2><p>将对象挂载在原型链是一个大忌，并且vue2也有警告，因为这样对于维护是一个非常大的问题，使用 forin会将内容显示出来</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">Object.prototype.a = &#123;&#125;</span><br></pre></td></tr></table></figure>



<h2 id="sass的使用"><a href="#sass的使用" class="headerlink" title="sass的使用"></a>sass的使用</h2><p>对于根项目的 uni.scss 我们在使用的时候不需要进行引入。</p>
<p>项目的 node_modules vue-cli-plugin-uni/lib/options.js 里面有引入</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">https://uniapp.dcloud.io/collocation/uni-scss</span><br></pre></td></tr></table></figure>



<h2 id="tabBar"><a href="#tabBar" class="headerlink" title="tabBar"></a>tabBar</h2><p>微信小程序的tabBar可以使用 page.json里面进行配置，不需要自己定义组件</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">https://uniapp.dcloud.io/collocation/pages?id=tabbar</span><br></pre></td></tr></table></figure>

<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">&#123;</span><br><span class="line">	&quot;tabBar&quot;: &#123;</span><br><span class="line">		&quot;color&quot;: &quot;#808080&quot;,</span><br><span class="line">		&quot;selectedColor&quot;: &quot;#007aff&quot;,</span><br><span class="line">		&quot;backgroundColor&quot;: &quot;#f8f8f8&quot;,</span><br><span class="line">		&quot;list&quot;: [</span><br><span class="line">			&#123;</span><br><span class="line">				&quot;text&quot;: &quot;主页&quot;,</span><br><span class="line">				&quot;iconPath&quot;: &quot;static/img/tab-bar/tab-bar-unselect.png&quot;,</span><br><span class="line">				&quot;selectedIconPath&quot;: &quot;static/img/tab-bar/tab-bar-select.png&quot;</span><br><span class="line">			&#125;</span><br><span class="line">		]</span><br><span class="line">	&#125;,</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>几个比较重要的属性</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">文字颜色</span><br><span class="line">color</span><br><span class="line">selectedColor</span><br><span class="line">背景颜色</span><br><span class="line">backgroundColor</span><br><span class="line"></span><br><span class="line">tab列表，是一个数组</span><br><span class="line">list</span><br></pre></td></tr></table></figure>

<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">list</span><br><span class="line">是一个数组，每个元素都是对象</span><br><span class="line"></span><br><span class="line">pagePath</span><br><span class="line">text</span><br><span class="line">iconPath</span><br><span class="line">selectedIconPath</span><br></pre></td></tr></table></figure>



<h2 id="路由-router"><a href="#路由-router" class="headerlink" title="路由 router"></a>路由 router</h2><p>微信小程序 没有路由</p>
<p>对应的在 pages.json 的 pages 里面可以进行配置，</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">&quot;pages&quot;: [ //pages数组中第一项表示应用启动页，参考：https://uniapp.dcloud.io/collocation/pages</span><br><span class="line">  &#123;</span><br><span class="line">    &quot;path&quot;: &quot;pages/index/index&quot;,</span><br><span class="line">    &quot;style&quot;: &#123;</span><br><span class="line">      &quot;navigationBarTitleText&quot;: &quot;uni-app&quot;</span><br><span class="line">    &#125;</span><br><span class="line">  &#125;</span><br><span class="line">],</span><br></pre></td></tr></table></figure>


    </div>

    
    
    

    <footer class="post-footer">
          <div class="post-tags">
              <a href="/tags/%E9%9A%8F%E7%AC%94/" rel="tag"># 随笔</a>
              <a href="/tags/%E9%A1%B9%E7%9B%AE/" rel="tag"># 项目</a>
              <a href="/tags/%E5%BE%AE%E4%BF%A1%E5%B0%8F%E7%A8%8B%E5%BA%8F/" rel="tag"># 微信小程序</a>
              <a href="/tags/uniapp/" rel="tag"># uniapp</a>
          </div>

        

          <div class="post-nav">
            <div class="post-nav-item">
                <a href="/2021/12/28/Node%20JS/NodeJS%E4%B8%8B%E8%BD%BD%E5%92%8Cnpm%E5%AE%89%E8%A3%85/" rel="prev" title="NodeJS下载和npm安装和配置">
                  <i class="fa fa-chevron-left"></i> NodeJS下载和npm安装和配置
                </a>
            </div>
            <div class="post-nav-item">
                <a href="/2022/01/11/%E9%9A%8F%E7%AC%94/other/jet-brains%E6%96%87%E4%BB%B6%E5%86%85%E5%AE%B9%E7%9A%84%E6%AD%A3%E5%88%99%E6%9F%A5%E6%89%BE%E5%92%8C%E6%9B%BF%E6%8D%A2/" rel="next" title="jet-brains文件内容的正则查找和替换">
                  jet-brains文件内容的正则查找和替换 <i class="fa fa-chevron-right"></i>
                </a>
            </div>
          </div>
    </footer>
  </article>
</div>






</div>
  </main>

  <footer class="footer">
    <div class="footer-inner">


<div class="copyright">
  &copy; 
  <span itemprop="copyrightYear">2023</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">tallgy</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" rel="noopener" target="_blank">Hexo</a> & <a href="https://theme-next.js.org/muse/" rel="noopener" target="_blank">NexT.Muse</a> 强力驱动
  </div>

    </div>
  </footer>

  
  <script src="https://cdn.jsdelivr.net/npm/animejs@3.2.1/lib/anime.min.js" integrity="sha256-XL2inqUJaslATFnHdJOi9GfQ60on8Wx1C2H8DYiN1xY=" crossorigin="anonymous"></script>
<script src="/js/comments.js"></script><script src="/js/utils.js"></script><script src="/js/motion.js"></script><script src="/js/schemes/muse.js"></script><script src="/js/next-boot.js"></script>

  





  





</body>
</html>
